window.addEventListener('load',function(){
    // 立即执行函数
    (function(){
        var swiper = new Swiper(".mySwiper1", {
            slidesPerView: 1,
            spaceBetween:0,
            loop: true,
            autoplay: {
              delay: 2500,
              disableOnInteraction: false,
            },
            pagination: {
              el: ".swiper-pagination",
              type: "fraction",
            },
            navigation: {
              nextEl: ".swiper-button-next",
              prevEl: ".swiper-button-prev",
            },
          });
    })();
    // 滚动条 滚到 300 的高度 让背景出来
    var header = document.querySelector('header');
    var top = document.querySelector('.top');
    window.addEventListener('scroll',function(){
        if(window.pageYOffset >= 300){
            header.style.backgroundColor = '#242424';
            top.style.opacity = '1'
        }else{
            header.style.backgroundColor = '';
            top.style.opacity = '0'

        }
    })
    // 点击播放
    var light_play = document.querySelector('.light_play')
    var light_mp4 = document.querySelector('.light_mp4');
    light_play.addEventListener('click',function(){
        light_mp4.style.display = 'block';
        // light_mp4.children[1]  指的是 视频本身video
        // play()播放视频
        light_mp4.children[1].play();
    });
    light_mp4.children[0].addEventListener('click',function(){
        light_mp4.style.display = 'none';
        // pause() 视频消失
        light_mp4.children[1].pause();
    });
    // 第二个轮播
    (function(){
        var swiper = new Swiper(".mySwiper2", {
            slidesPerView: 1,
            spaceBetween:0,
            loop: true,
            autoplay: {
              delay: 2500,
              disableOnInteraction: false,
            },
            pagination: {
              el: ".swiper-pagination",
              type: "progressbar",
            },
            navigation: {
              nextEl: ".swiper-button-next",
              prevEl: ".swiper-button-prev",
            },
          });
    })();
})